//
//  HYDeviceManagerVC.m
//  TJHYHardwareProduct
//
//  Created by yc on 2017/12/25.
//  Copyright © 2017年 Cong Yao. All rights reserved.
//

#import "HYDeviceManagerVC.h"
#import "HYDeviceManagerView.h"
#import "HYDeviceTableViewCell.h"
#import "HYDataCheckVC.h"
#import "HYEditDeviceVC.h"
#import "HYCustonSearchBar.h"
#import "HYDeviceListApi.h"
#import "TWSelectCityView.h"
#import "HYGetMainCompanyListApi.h"
#import "HYGetChildCompanyListApi.h"
#import "DTPickerManager.h"
#import "HYGetDeviceAreaApi.h"
#import "HYFiltrateTableView.h"
#import "HYAreaModel.h"
#import "AlertViewManager.h"
#import "HYDeviceControlApi.h"
#import "HYDeviceTypeListApi.h"

@interface HYDeviceManagerVC ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong)HYDeviceManagerView *containerView;
@property(nonatomic,strong)HYCustonSearchBar *searchBar;
@property(nonatomic,strong)NSMutableArray *dataSource;
@property(nonatomic,strong)NSMutableArray *allDataSource;
@property(nonatomic,strong)NSMutableArray *filtrateDataSource;


@property(nonatomic,strong)HYMainCompanyModel *companyModel;
@property(nonatomic,strong)HYChildCompanyModel *childCompanyModel;
@property(nonatomic,strong)HYDeviceAreaModel *deviceAreaModel;
@property(nonatomic,strong)HYAreaModel *areaModel;
@property(nonatomic,strong)HYDeviceTypeModel *deviceTypeModel;

@property(nonatomic,assign)int page;
@property(nonatomic,strong)UILabel *emptyLabel;
@property(nonatomic,assign)BOOL deviceAreaNoData;


@end

@implementation HYDeviceManagerVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self updateData];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateData) name:@"EditDevice" object:nil];
}

- (void)updateData
{
    self.page = 1;
    [self updateDeviceListWithPage:self.page];
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
//    self.page = 1;
//    [self updateDeviceListWithPage:self.page];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [self cancelFiltrat];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

#pragma mark --- 事件处理
- (void)updateDeviceListWithPage:(int)page
{
    [HYDeviceListApi getListPage:page dno:nil province:nil city:nil district:nil cid:nil child_cid:nil dong:nil ceng:nil fang:nil success:^(NSArray<HYDeviceInfoModel *> *list) {
        [self.containerView.tableView.mj_footer endRefreshing];
        [self.containerView.tableView.mj_header endRefreshing];
        
        if (self.page == 1)
        {
            if (list.count == 0)
            {
                self.emptyLabel.hidden = NO;
            }
            else
            {
                self.emptyLabel.hidden = YES;
            }
            [self.dataSource removeAllObjects];
            [self.allDataSource removeAllObjects];
            
            [self.allDataSource addObjectsFromArray:list];
            [self.dataSource addObjectsFromArray:list];
            [self.containerView.tableView reloadData];
        }
        else
        {
            if (list.count != 0)
            {
                [self.dataSource addObjectsFromArray:list];
                [self.allDataSource addObjectsFromArray:list];
                [self.containerView.tableView reloadData];
            }
            else
            {
                [self.containerView.tableView.mj_footer endRefreshingWithNoMoreData];
            }

        }

    } fail:^(NSDictionary *dic) {
        [self.containerView.tableView.mj_footer endRefreshing];
        [self.containerView.tableView.mj_header endRefreshing];
    }];
}

- (void)showChooseWithIndex:(NSInteger)index
{
    switch (index)
    {
        case 0:
            [self showDevieTypeChoose];
            break;
        case 1:
            [self showAreaChoose];
            break;
        case 2:
            [self showCompanyChoose];
            break;
        case 3:
            [self showChildCompanyChoose];
            break;
        case 4:
//            [self showAlertViewWithTitle:@"栋"];
            [self showDongChoose];
            break;
        case 5:
//            [self showAlertViewWithTitle:@"层"];
            [self showCengChoose];
            break;
        case 6:
//            [self showAlertViewWithTitle:@"房"];
            [self showFangChoose];
            break;
        case 10: // 取消按钮
        {
            [self cancelFiltrat];
        }
            break;
        case 11: // 确认按钮
            [self getFiltrateData];
            break;
        case 12: // 筛选按钮收起
            {
                [self clearFiltrat];
            }
        case 13: // 筛选按钮展开
        {
            [self.searchBar.searchTextField resignFirstResponder];
        }
//            [self getFiltrateData];
            break;
            
        default:
            break;
    }
}

// 取消筛选
- (void)cancelFiltrat
{
    [self clearFiltrat];
    [self.containerView hideFiltrateView];
}

- (void)clearFiltrat
{
    self.areaModel = [HYAreaModel new];
    self.companyModel = [HYMainCompanyModel new];
    self.childCompanyModel = [HYChildCompanyModel new];
    self.filtrateDataSource = [NSMutableArray arrayWithArray:@[@"",@"",@"",@"",@"",@"",@""]];
}

// 获取筛选数据
- (void)getFiltrateData
{
    [HYDeviceListApi getListPage:1 dno:nil province:_areaModel.province city:_areaModel.city district:_areaModel.distr cid:_companyModel.id child_cid:_childCompanyModel.id dong:_filtrateDataSource[4] ceng:_filtrateDataSource[5] fang:_filtrateDataSource[6] success:^(NSArray<HYDeviceInfoModel *> *list) {
        [self.dataSource removeAllObjects];
        [self.allDataSource removeAllObjects];
        
        [self.allDataSource addObjectsFromArray:list];
        [self.dataSource addObjectsFromArray:list];
        [self.containerView.tableView reloadData];
        [self.containerView.tableView.mj_footer endRefreshingWithNoMoreData];
    } fail:^(NSDictionary *dic) {
        [SVProgressHUD showErrorWithStatus:dic[@"errmsg"]];
    }];
}

// 设备类型选择
- (void)showDevieTypeChoose
{
    [HYDeviceTypeListApi getDeviceType:^(NSArray<HYDeviceTypeModel *> *list) {
        NSMutableArray *array = [NSMutableArray arrayWithCapacity:4];
        for (HYDeviceTypeModel *model in list) {
            [array addObject:model.name];
        }
        __weak typeof(self) weakSelf = self;
        [DTPickerManager shareManager].isFullScreen = 1;
        [DTPickerManager shareManager].dataArray = @[array];
        [[DTPickerManager shareManager] showPickerAndCancel:^(NSArray *arr) {
            
        } andConfirm:^(NSArray *arr) {
            NSInteger index = [arr.firstObject intValue];
            if (list.count == 0) return;
            weakSelf.deviceTypeModel = list[index];
            [weakSelf.filtrateDataSource replaceObjectAtIndex:0 withObject:weakSelf.deviceTypeModel.name];
            [weakSelf updateFiltrateTableView];
        }];
    } fail:^(NSDictionary *dic) {
        
    }];
    
}

// 地区选择
- (void)showAreaChoose
{
    //    [self hideKeyBoard];
    __weak typeof(self) weakSelf = self;
    TWSelectCityView *city = [[TWSelectCityView alloc] initWithTWFrame:[AppDelegate defaultService].window.bounds TWselectCityTitle:@"选择地区"];
    [city showCityView:^(NSString *proviceStr, NSString *cityStr, NSString *distr) {
        [weakSelf clearFiltrat];
        
        weakSelf.areaModel = [HYAreaModel new];
        weakSelf.areaModel.province = proviceStr;
        weakSelf.areaModel.city = cityStr;
        weakSelf.areaModel.distr = distr;
        [weakSelf.filtrateDataSource replaceObjectAtIndex:1 withObject:[weakSelf.areaModel getArea]];
        [weakSelf updateFiltrateTableView];
    }];
    
}



// 选择公司
- (void)showCompanyChoose
{
    [SVProgressHUD showWithStatus:@"请稍候..."];
    [HYGetMainCompanyListApi getCompanyMainListProvince:_areaModel.province city:_areaModel.city district:_areaModel.distr success:^(NSArray<HYMainCompanyModel *> *list) {
        [SVProgressHUD dismiss];
        __weak typeof(self) weakSelf = self;
        NSMutableArray *array = [NSMutableArray arrayWithCapacity:4];
        for (HYMainCompanyModel *model in list) {
            [array addObject:model.company_name];
        }
        if (array.count == 0)
        {
            [SVProgressHUD showInfoWithStatus:@"没有数据"];
            return;
        }
        [DTPickerManager shareManager].isFullScreen = 1;
        [DTPickerManager shareManager].dataArray = @[array];
        [[DTPickerManager shareManager] showPickerAndCancel:^(NSArray *arr) {
            
        } andConfirm:^(NSArray *arr) {
            NSInteger index = [arr.firstObject intValue];
            if (list.count == 0) return;
            weakSelf.companyModel = list[index];
            [weakSelf.filtrateDataSource replaceObjectAtIndex:2 withObject:weakSelf.companyModel.company_name];
            [weakSelf.filtrateDataSource replaceObjectAtIndex:4 withObject:@""];
            [weakSelf.filtrateDataSource replaceObjectAtIndex:5 withObject:@""];
            [weakSelf.filtrateDataSource replaceObjectAtIndex:6 withObject:@""];

            [weakSelf updateFiltrateTableView];
            
            [HYGetDeviceAreaApi getDeviceAreaList:[weakSelf.companyModel.id intValue] success:^(NSArray<HYDeviceAreaModel *> *list) {
                if (list.count == 0)
                {
                    weakSelf.deviceAreaNoData = YES;
                }
                else
                {
                    weakSelf.deviceAreaModel = list.firstObject;
                }
            } fail:^(NSDictionary *dic) {
                
            }];
        }];
    } fail:^(NSDictionary *dic) {
        [SVProgressHUD dismiss];
    }];
}

// 选择分支
- (void)showChildCompanyChoose
{
    if (!self.companyModel.id)
    {
        [SVProgressHUD showErrorWithStatus:@"请先选择公司"];
        return;
    }
    [SVProgressHUD showWithStatus:@"请稍候..."];
    [HYGetChildCompanyListApi getCompanyChildList:[self.companyModel.id intValue] Province:_areaModel.province city:_areaModel.city district:_areaModel.distr success:^(NSArray<HYChildCompanyModel *> *list) {
        [SVProgressHUD dismiss];
        __weak typeof(self) weakSelf = self;
        NSMutableArray *array = [NSMutableArray arrayWithCapacity:4];
        for (HYChildCompanyModel *model in list) {
            [array addObject:model.company_name];
        }
        
        if (array.count == 0)
        {
            [SVProgressHUD showInfoWithStatus:@"无分支机构"];
            return;
        }
        else
        {
            [DTPickerManager shareManager].isFullScreen = 1;
            [DTPickerManager shareManager].dataArray = @[array];
            [[DTPickerManager shareManager] showPickerAndCancel:^(NSArray *arr) {
                
            } andConfirm:^(NSArray *arr) {
                NSInteger index = [arr.firstObject intValue];
                if (list.count == 0) return;
                weakSelf.childCompanyModel = list[index];
                [weakSelf.filtrateDataSource replaceObjectAtIndex:3 withObject:weakSelf.childCompanyModel.company_name];
                [weakSelf updateFiltrateTableView];
            }];
        }

    } fail:^(NSDictionary *dic) {
        [SVProgressHUD dismiss];
    }];
}

- (void)showDongChoose
{
    __weak typeof(self) weakSelf = self;
    if (self.deviceAreaNoData)
    {
        [SVProgressHUD showInfoWithStatus:@"没有数据"];
        return;
    }
    
    if (_deviceAreaModel == nil)
    {
        [SVProgressHUD showErrorWithStatus:@"请先选择公司"];
        return;
    }
    NSArray *array = _deviceAreaModel.dong;
    if (array.count == 0)
    {
        [SVProgressHUD showErrorWithStatus:@"没有可选"];
        return;
    }
    [DTPickerManager shareManager].isFullScreen = 1;
    [DTPickerManager shareManager].dataArray = @[array];
    [[DTPickerManager shareManager] showPickerAndCancel:^(NSArray *arr) {
        
    } andConfirm:^(NSArray *arr) {
        
        if (array.count == 0) return;
        [weakSelf.filtrateDataSource replaceObjectAtIndex:4 withObject:array[[arr.firstObject intValue]]];
        [weakSelf updateFiltrateTableView];
    }];
}

- (void)showCengChoose
{
    __weak typeof(self) weakSelf = self;
    if (self.deviceAreaNoData)
    {
        [SVProgressHUD showInfoWithStatus:@"没有数据"];
        return;
    }
    if (_deviceAreaModel == nil)
    {
        [SVProgressHUD showErrorWithStatus:@"请先选择公司"];
        return;
    }
    NSArray *array = _deviceAreaModel.ceng;
    if (array.count == 0)
    {
        [SVProgressHUD showErrorWithStatus:@"没有可选"];
        return;
    }
    [DTPickerManager shareManager].isFullScreen = 1;
    [DTPickerManager shareManager].dataArray = @[array];
    [[DTPickerManager shareManager] showPickerAndCancel:^(NSArray *arr) {
        
    } andConfirm:^(NSArray *arr) {
        
        if (array.count == 0) return;
        [weakSelf.filtrateDataSource replaceObjectAtIndex:5 withObject:array[[arr.firstObject intValue]]];
        [weakSelf updateFiltrateTableView];
    }];
}

- (void)showFangChoose
{
    __weak typeof(self) weakSelf = self;
    if (self.deviceAreaNoData)
    {
        [SVProgressHUD showInfoWithStatus:@"没有数据"];
        return;
    }
    
    if (_deviceAreaModel == nil)
    {
        [SVProgressHUD showErrorWithStatus:@"请先选择公司"];
        return;
    }
    NSArray *array = _deviceAreaModel.fang;
    if (array.count == 0)
    {
        [SVProgressHUD showErrorWithStatus:@"没有可选"];
        return;
    }
    [DTPickerManager shareManager].isFullScreen = 1;
    [DTPickerManager shareManager].dataArray = @[array];
    [[DTPickerManager shareManager] showPickerAndCancel:^(NSArray *arr) {
        
    } andConfirm:^(NSArray *arr) {
        
        if (array.count == 0) return;
        [weakSelf.filtrateDataSource replaceObjectAtIndex:6 withObject:array[[arr.firstObject intValue]]];
        [weakSelf updateFiltrateTableView];
    }];
}

- (void)showAlertViewWithTitle:(NSString *)title
{
    __weak typeof(self) weakSelf = self;
    [[AlertViewManager shareManager] initWithEditActionTitle:title message:nil cancleButtonTitle:@"取消" OtherButtonsArray:@[@"确认"] clickAtIndex:^(NSInteger buttonIndex, UIAlertController *alertController) {
        if (buttonIndex == 1) {
            NSString *string = alertController.textFields.firstObject.text;
            if (alertController.textFields.firstObject.text.length == 0) {
                [SVProgressHUD showErrorWithStatus:[NSString stringWithFormat:@"%@不能为空",title]];
                return;
            }
            if (alertController.textFields.firstObject.text.length > 10) {
                [SVProgressHUD showErrorWithStatus:[NSString stringWithFormat:@"%@不能超过20个字符",title]];
                return;
            }
            
            if ([NSString isContainsTwoEmoji:alertController.textFields.firstObject.text] ) {
                [SVProgressHUD showErrorWithStatus:[NSString stringWithFormat:@"%@不能使用表情",title]];
                return;
            }
            
            if ([title isEqualToString:@"栋"]) {
                [weakSelf.filtrateDataSource replaceObjectAtIndex:4 withObject:string];
            }else if ([title isEqualToString:@"层"]){
                [weakSelf.filtrateDataSource replaceObjectAtIndex:5 withObject:string];
            }else if ([title isEqualToString:@"房"]){
                [weakSelf.filtrateDataSource replaceObjectAtIndex:6 withObject:string];
            }else if ([title isEqualToString:@"失联时间"]){
                NSInteger num = [string intValue];
                if (num <= 0)
                {
                    [SVProgressHUD showErrorWithStatus:@"请输入正确的失联时间"];
                    return;
                }
//                weakSelf.lostTime = string;
            }
            [weakSelf updateFiltrateTableView];
//            [weakSelf.tableView reloadData];
        }
    }];
    
}

// 更新筛选列表
- (void)updateFiltrateTableView
{
    [self.containerView updateFiltrateTableView:self.filtrateDataSource];
}

#pragma mark - tableView代理
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return self.dataSource.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return px1920Height(560);
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return px1920Height(30);
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return CGFLOAT_MIN;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    HYDeviceTableViewCell *cell = [HYDeviceTableViewCell cellWithTableView:tableView forIndexPath:indexPath];
    HYDeviceInfoModel *model = self.dataSource[indexPath.section];
    [cell updateDeviceInfo:model];
    __weak typeof(self) weakSelf = self;
    cell.checkBlock = ^{
        HYDataCheckVC *vc = [HYDataCheckVC new];
        vc.deivceID = model.id;
        vc.hidesBottomBarWhenPushed = YES;
        [weakSelf.navigationController pushViewController:vc animated:YES];
    };
    cell.editBlock = ^{
        HYEditDeviceVC *vc = [HYEditDeviceVC new];
        vc.hidesBottomBarWhenPushed = YES;
        vc.deviceInfoModel = model;
        [weakSelf.navigationController pushViewController:vc animated:YES];
    };
    cell.switchBlock = ^(int state) {
//        NSString *string = [NSString stringWithFormat:@"%i",state];
//        NSDictionary *dict = @{@"device_id":model.id,@"status":string};
//        HYDeviceControlApi *api = [[HYDeviceControlApi alloc] initWithDic:dict];
//        [api dtStartYTKRequestCompletionBlockWithSuccess:^(YTKBaseRequest * _Nonnull request) {
//            
//        } failure:^(YTKBaseRequest * _Nonnull request) {
//            
//        }];
        [HYDeviceControlApi controlDevice:model.id status:state success:^(NSDictionary *dic) {

        } fail:^(NSDictionary *dic) {
            [SVProgressHUD showErrorWithStatus:dic[@"errmsg"]];
            [weakSelf.containerView.tableView reloadData];
        }];
    };
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    [self cancelFiltrat];
}

//- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    // 首先修改model
////    [self.books removeObjectAtIndex:indexPath.row];
////    // 之后更新view
////    [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
//}
//
//- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    return @"删除";
//}

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
    return UITableViewCellEditingStyleDelete | UITableViewCellEditingStyleInsert;
}



#pragma mark - 监听textField的变化
-(void)textFieldTextChange:(UITextField *)textField
{
    if (textField.text.length == 0)
    {
        self.dataSource = self.allDataSource;
    }
    else
    {
        NSMutableArray *dataArray = [[NSMutableArray alloc] init];
        for (HYDeviceInfoModel *model in self.allDataSource)
        {
            if ([model.dno containsString:textField.text])
            {
                [dataArray addObject:model];
            }
        }
        self.dataSource = dataArray;
    }
    if (self.dataSource.count == 0)
    {
        self.emptyLabel.hidden = NO;
    }
    else
    {
        self.emptyLabel.hidden = YES;
    }
    [self.containerView.tableView reloadData];
    [self.containerView.tableView.mj_footer endRefreshingWithNoMoreData];
}

- (void)textFieldTextStartEdit:(UITextField *)textField
{
    [self cancelFiltrat];
}

#pragma mark - 懒加载
- (HYDeviceManagerView *)containerView
{
    if(!_containerView)
    {
        UIView *superView = self.view;
        _containerView = [[HYDeviceManagerView alloc]init];
        [superView addSubview:_containerView];
//        _containerView.tableView.editing = YES;
        _containerView.tableView.delegate = self;
        _containerView.tableView.dataSource = self;
        _containerView.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _containerView.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
            self.page = 1;
            [self updateDeviceListWithPage:self.page];
        }];
        _containerView.tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
            self.page ++;
            [self updateDeviceListWithPage:self.page];
        }];
        __weak typeof(self) weakSelf = self;
        _containerView.filtrateBlock = ^(NSInteger index) {
            [weakSelf showChooseWithIndex:index];
        };
    }
    return _containerView;
}



- (HYCustonSearchBar *)searchBar
{
    if(!_searchBar)
    {
        UIView *superView = self.navigationBar;
        _searchBar = [[HYCustonSearchBar alloc]init];
        [superView addSubview:_searchBar];
        _searchBar.searchTextField.placeholder = @"请输入设备编号";
        _searchBar.searchTextField.keyboardType = UIKeyboardTypeNumberPad;
        _searchBar.searchTextField.clearButtonMode=UITextFieldViewModeWhileEditing;
        [_searchBar.searchTextField addTarget:self action:@selector(textFieldTextChange:) forControlEvents:UIControlEventEditingChanged];
        [_searchBar.searchTextField addTarget:self action:@selector(textFieldTextStartEdit:) forControlEvents:UIControlEventEditingDidBegin];
        _searchBar.backgroundColor = rgba(234,234,234,1);
        _searchBar.layer.cornerRadius = px1920Height(100)/2;
        
    }
    return _searchBar;
}

- (NSMutableArray *)dataSource
{
    if(!_dataSource)
    {
        _dataSource = [[NSMutableArray alloc]init];
    }
    return _dataSource;
}

- (NSMutableArray *)allDataSource
{
    if(!_allDataSource)
    {
        _allDataSource = [[NSMutableArray alloc]init];
    }
    return _allDataSource;
}

- (NSMutableArray *)filtrateDataSource
{
    if(!_filtrateDataSource)
    {
        _filtrateDataSource = [NSMutableArray arrayWithArray:@[@"",@"",@"",@"",@"",@"",@""]];
    }
    return _filtrateDataSource;
}

- (UILabel *)emptyLabel
{
    if(!_emptyLabel)
    {
        UIView *superView = self.view;
        _emptyLabel = [[UILabel alloc]init];
        [superView addSubview:_emptyLabel];
        _emptyLabel.font = fontWithSize(15);
        _emptyLabel.textColor = [UIColor darkGrayColor];
        _emptyLabel.text = @"暂无满足条件的数据";
    }
    return _emptyLabel;
}

#pragma mark - 布局
- (void)base_masLayoutSubview
{
    __weak UIView *superView = self.view;
    superView.backgroundColor = rgba(245,245,245,1);
    
    [self.containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(superView.mas_top).with.offset(64);
        make.left.right.bottom.mas_equalTo(superView);
    }];
    
    
    [self.searchBar mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.navigationBar.mas_centerX);
        make.width.mas_equalTo(px1080Width(949));
        make.height.mas_equalTo(px1920Height(100));
        make.bottom.mas_equalTo(self.navigationBar.mas_bottom).with.offset(-px1920Height(27));
    }];
    
    
    [self.view sendSubviewToBack:self.containerView];
    
    [self.emptyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.mas_equalTo(superView);
    }];

}



#pragma mark - 导航栏
- (void)base_configNavigationBar
{
    self.navigationBar.backgroundColor = [UIColor whiteColor];
}



@end
